package com.ibuonline.b2b.admin.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import org.springframework.jdbc.core.RowMapper;

import com.dimeng.common.base.SuperDAO;
import com.ibuonline.b2b.entity.ProdCategory;

public class ProdCategoryDAO extends SuperDAO<ProdCategory> {

	@SuppressWarnings("unchecked")
	public Map<Integer,Integer> getCatCount(){
		String sql = "SELECT cat_id,COUNT(*) AS count FROM company_to_category GROUP BY cat_id  ORDER BY count desc";
		final Map<Integer,Integer> map = new HashMap<Integer,Integer>();
		jdbcTemplate.query(sql, new RowMapper(){
			public Object mapRow(ResultSet rs, int i) throws SQLException {
				map.put(rs.getInt("cat_id"),rs.getInt("count"));
				return null;
			}
		});
		return map;
	}
	
	
	
}
